package com.cdut.hwadeefsc.service.impl;

import com.cdut.hwadeefsc.entity.homework;
import com.cdut.hwadeefsc.mapper.homeworksMapper;
import com.cdut.hwadeefsc.service.homeworksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class homeworksServiceImpl implements homeworksService {

    @Autowired
    private homeworksMapper homeworkMapper;

    @Override
    public List<homework> getHomeworkByClassId(Integer classId) {
        return homeworkMapper.findByClassId(classId);
    }

    @Override
    public List<homework> getHomeworkByStudentId(Integer studentId) {
        return homeworkMapper.findByStudentId(studentId);
    }

    @Override
    public homework getHomeworkById(Integer id) {
        return homeworkMapper.findById(id);
    }

    @Override
    public boolean addHomework(homework homework) {
        return homeworkMapper.insert(homework) > 0;
    }

    @Override
    public boolean updateHomework(homework homework) {
        return homeworkMapper.update(homework) > 0;
    }

    @Override
    public boolean deleteHomework(Integer id) {
        return homeworkMapper.delete(id) > 0;
    }

    @Override
    public List<homework> getHomeworkByCourse(String courseName) {
        // 这里需要在Mapper中添加对应的方法
        return homeworkMapper.findByCourseName(courseName);
    }

    @Override
    public List<homework> getActiveHomework() {
        // 这里需要在Mapper中添加对应的方法
        return homeworkMapper.findActiveHomework();
    }
}




